package com.wrupple.muba.catalogs.client.activity.process;

import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;
import com.wrupple.muba.catalogs.client.activity.process.impl.ImportDataHandler;
import com.wrupple.muba.catalogs.client.activity.process.state.BrowsePlaceInterpret;
import com.wrupple.muba.catalogs.client.module.services.presentation.CatalogPlaceInterpret;
import com.wrupple.muba.catalogs.domain.CatalogProcessDescriptor;
import com.wrupple.muba.common.client.activity.ActivityProcess;
import com.wrupple.muba.common.client.activity.ArbitraryActivityExit;
import com.wrupple.muba.common.domain.DesktopPlace;
import com.wrupple.muba.common.shared.SequentialProcess;
import com.wrupple.muba.widget.client.view.Task;

/**
 * 
 * <ol>
 * 		<li>interpret place (get catalog)</li>
 * 		<li>read csv to import</li>
 * 		<li>parse csv into entries</li>
 * 		<li>create all entries</li>
 * 		<li>go to Exit Place</li>
 * </ol>
 * 
 * @author japi
 * 
 */
public class CatalogImportActivityProcess extends SequentialProcess<DesktopPlace, DesktopPlace> implements
		ActivityProcess {
	
	public static class ImportData {
		public String catalog;
		public String[] columnNames;
		public List<JavaScriptObject> csv;
		public ImportData(String catalog, String[] columnNames,
				List<JavaScriptObject> csv) {
			super();
			this.catalog = catalog;
			this.columnNames = columnNames;
			this.csv = csv;
		}
	}

	public CatalogImportActivityProcess(CatalogPlaceInterpret interpret,DesktopPlace exitPlace,Task<CatalogProcessDescriptor, ImportData> view, BrowsePlaceInterpret red,ImportDataHandler importHandler) {
		super();
		//interpret catalog ->Place interpretation
		red.setPlaceInterpret(interpret);
		addState(red);
		//read csv ->  ImportData
		addState(view);
		//create entries -> List<CatalogEntry>
		addState(importHandler);
		//exit
		addState(new ArbitraryActivityExit(exitPlace));
	}
	
	
}
